﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace PPCodes.LoadingBox
{
    public partial class LoadingBox : Form
    {
        public LoadingBox()
        {
            InitializeComponent();
        }

        private delegate void StatusChangedHandle(string text);

        public void SetStatusInfo()
        {
            
            SetLabText("正加载工具栏. . .");
            Thread.Sleep(500);
           
            SetLabText("正在读取配置文件. . .");
            Thread.Sleep(500);

            SetLabText("正在初始化设计器. . .");
            Thread.Sleep(500);

            SetLabText("正在启动主窗体. . .");

            DialogResult = DialogResult.OK;
        }

        public void SetLabText(string texts)
        {
            if (lblStatus.InvokeRequired)
            {
                lblStatus.Invoke(new StatusChangedHandle(SetLabText), new object[] { texts });
            }
            else
            {
                lblStatus.Text = texts;
            }
        }

        public void SetVer(string ver)
        {
            lblVer.Text = ver;
        }

        private void LoadingBox_Load(object sender, EventArgs e)
        {
            var th = new Thread(SetStatusInfo);
            th.IsBackground = true;
            th.Start();
        }
    }
}
